package utils
{
	import mx.collections.ArrayCollection;
	
	public class DataAnalyzer
	{
		/**
		 * This function return column names according to first row in data which is ArrayCollection.
		 * It is supposed that first item in data collection is an object. Properties' names of this 
		 * object are returned in ArrayCollection.
		 * 
		 * If data has no rows, null is returned.
		 */
		public static function getColumnNames(data:ArrayCollection):ArrayCollection {
			if (data != null && data.length > 0) {
				var columnNames:ArrayCollection = new ArrayCollection();
				var testedRow:Object = data.getItemAt(0);
				for(var propertyName:String in testedRow) {
  					columnNames.addItem(propertyName);
				}
				return columnNames;
			} else {
				return null;
			}
		}

	}
}